package com.corffen.design.state;

public class WiFiController {

    private IState mState;
    private boolean mToggleIsEnable;

    public WiFiController() {
        mState = new WifiCloseState();
    }

    public void setState(IState state) {
        mState = state;
    }

    public void connect() {
        setEnable(true);
    }

    public void disconnect() {
        setEnable(false);
    }

    public void setEnable(boolean toggle) {
        mToggleIsEnable = toggle;
        mState = mToggleIsEnable ? new OpenWifiState() : new WifiCloseState();
    }

    public void changeWifi(String msg) {
        if (mToggleIsEnable) {
            mState = new ChangeWiFiState();
        }
        mState.processMessage("切换到:" + msg);
    }
}
